<?php
declare (strict_types = 1);
namespace security;

/**
 * https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/provisioning/JdbcUserDetailsManager.html
 */
interface UserDetailsService {

    /**
     * Locates the user based on the username.
     */
    public function loadUserByUsername(string $username): UserDetails;

    /**
     * Allows subclasses to add their own granted authorities to the list to be returned in the UserDetails.
     */
    public function addCustomAuthorities(string $username, array $authorities);

    /**
     * Modify the current user's password.
     */
    public function changePassword(string $oldPassword, string $newPassword);

    /**
     * Modify the specified user's password.
     */
    public function updatePassword(UserDetails $user, string $newPassword);

    /**
     * Create a new user with the supplied details.
     */
    public function createUser(UserDetails $user);

    /**
     * Create a new user with the supplied details.
     */
    public function updateUser(UserDetails $user);

    /**
     * Check if a user with the supplied login name exists in the system.
     */
    public function userExists(string $username): bool;

    /**
     * Remove the user with the given login name from the system.
     */
    public function deleteUser(string $username);

}